package offer_test_40;

//输入一个字符串，打印出该字符串中字符的所有排列。不考虑重复字符
public class eight_StringPermutation {
	public static void main(String[] args) {
		String input = "abc";
		printSP(input);
	}

	public static void printSP(String str) {
		if (str.length() <= 1) {
			System.out.println(str);
		} else {
			printString("", str);
		}
	}

	public static void printString(String str, String str2) {
		if (str2.length() == 1) {
			System.out.println(str+str2);
		} else {
			int k=str2.length();
			for (int i = 0; i < k; i++) {
				String trans = str2.charAt(i) + "";
				String changehead = str+trans;
				String changestr = deleteAti(str2,i);
				printString(changehead, changestr);
			}
		}
	}
	
	public static String deleteAti(String str,int i){
		String rs="";
		rs=str.substring(0, i);
		rs=rs+str.substring(i+1, str.length());
		return rs;
	}
}
